//我的订单
let express = require('express');
let path = require('path');
//引入自定义模块
let user = require('../model/user');
let order = require('../model/order');

var router = express.Router();


router.get('/',function(req,res,next){
    res.sendStatus(404);
    //_dirname:当前文件的路径，path.join():合并路径
});
/**
 *登录验证功能
 */
router.post('/',function (req,res,next){
    let orderID = req.body.orderID;
    let token = req.body.token;
    order.searchID(orderID,function (result){
        if(user.checkToken(result[0].userID,token) == false){
            res.send({myorderInfoStatus:2});
        }
        else {
            if(result.length === 0){
                res.send({myorderInfoStatus:1});
            }
            else {
                result[0].myorderInfoStatus = 0;
                res.send(result[0]);
            }
        }
    })
})
module.exports = router;